home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / g_quake / server~1.zip / _WELDGUN.QC < prev    next >
Text File  |  1996-10-04  |  6KB  |  200 lines

  1. /*
  2. **
  3. ** _weldgun.qc (WeldGun Code, 1.0)
  4. **
  5. ** Copyright (C) 1996 Johannes Plass
  6. ** 
  7. ** This program is free software; you can redistribute it and/or modify
  8. ** it under the terms of the GNU General Public License as published by
  9. ** the Free Software Foundation; either version 2 of the License, or
  10. ** (at your option) any later version.
  11. ** 
  12. ** This program is distributed in the hope that it will be useful,
  13. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. ** GNU General Public License for more details.
  16. **
  17. ** You should have received a copy of the GNU General Public License
  18. ** along with this program; if not, write to the Free Software
  19. ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. ** 
  21. ** Author:   Johannes Plass (plass@dipmza.physik.uni-mainz.de)
  22. **
  23. */
  24.  
  25. void(entity player) WeldInfo =
  26. {
  27.   if (!USE_MODULE_WELDGUN) return;
  28.  
  29.               // 123456789#123456789#123456789#12345678
  30.   sprint(player,"£");
  31.   sprint(player," WeldGun");
  32.   sprint(player,        " lets the nailgun spit metal\n");
  33.   sprint(player,"  blobs. Use 'help-weldgun' for help.\n");
  34. };
  35.  
  36. void(entity player) WeldInit =
  37. {
  38.   if (!USE_MODULE_WELDGUN) return;
  39.  
  40.   stuffcmd(player,"alias help-weldgun \"impulse 217\";\n");
  41. };
  42.  
  43. void(entity player) WeldActiveMessage =
  44. {
  45.   if (!USE_MODULE_WELDGUN) return;
  46.  
  47.               // 123456789#123456789#123456789#12345678
  48.   sprint(player,"  WeldGun       (help-weldgun)\n");
  49. };
  50.  
  51. void(entity player) WeldHelp =
  52. {
  53.   if (!USE_MODULE_WELDGUN) return;
  54.  
  55.               // 123456789#123456789#123456789#12345678
  56.   sprint(player,"WeldGun:");
  57.   sprint(player,        " spits burning blobs of a\n");
  58.   sprint(player,"magnesium-steel mixture in rapid\n");
  59.   sprint(player,"succession.\n");
  60.   sprint(player,"To use it select the nailgun. Select\n");
  61.   sprint(player,"it again to shoot spikes instead.\n");
  62.   sprint(player,"The silver key is lit if the weldgun\n");
  63.   sprint(player,"is active.\n");
  64.   sprint(player,"Players hit by burning blobs may\n");
  65.   sprint(player,"start to burn.\n");
  66. };
  67.  
  68. //========================================================================
  69. //   WeldToggleWeapon
  70. //========================================================================
  71.  
  72. void(entity player) WeldToggleWeapon =
  73. {
  74.   if (!USE_MODULE_WELDGUN) return;
  75.   
  76.   if (player.modules_weapon & MODULES_WEAPON_WELD) {
  77.     player.modules_weapon = player.modules_weapon - MODULES_WEAPON_WELD;
  78.     player.items = player.items - (player.items & IT_KEY1);
  79.   } else {
  80.     if ((player.weapon == IT_NAILGUN) && (player.ammo_nails >= 1)) {
  81.       player.modules_weapon = player.modules_weapon | MODULES_WEAPON_WELD;
  82.       player.items = player.items | IT_KEY1;
  83.     }
  84.   }
  85. };
  86.  
  87. //========================================================================
  88. //   WeldResetWeapon
  89. //========================================================================
  90.  
  91. void(entity player) WeldResetWeapon =
  92. {
  93.    if (!USE_MODULE_WELDGUN) return;
  94.    if (player.modules_weapon & MODULES_WEAPON_WELD) {
  95.       player.modules_weapon = player.modules_weapon - MODULES_WEAPON_WELD;
  96.       player.items = player.items - (player.items & IT_KEY1);
  97.    }
  98. };
  99.  
  100. //==================================================================
  101. //   WeldFire
  102. //==================================================================
  103.  
  104. void(vector org, vector dir) WeldFire =
  105. {
  106.   local entity weld;
  107.  
  108.   weld                = spawn();
  109.   weld.owner          = self;
  110.   weld.movetype       = MOVETYPE_FLYMISSILE;
  111.   weld.solid          = SOLID_BBOX;
  112.   weld.touch          = WeldTouch;
  113.   weld.classname      = "weld_blob";
  114.   weld.think          = SUB_Remove;
  115.   weld.nextthink      = time + 6;
  116.   weld.velocity       = dir * 1000;
  117.   weld.angles         = vectoangles(weld.velocity);
  118.   weld.angles_x       = weld.angles_x + 90;
  119.   weld.modules_weapon = MODULES_WEAPON_WELD;
  120.   if (time >= weld.owner.weld_light_time) {
  121.     weld.effects = weld.effects | EF_DIMLIGHT;
  122.     weld.owner.weld_light_time = time + 0.2;
  123.   }
  124.  
  125.   setmodel (weld, "progs/flame2.mdl");
  126.   setsize (weld, VEC_ORIGIN, VEC_ORIGIN);        
  127.   setorigin (weld, org - '0 0 6' + dir*8);
  128.   sound (weld.owner, CHAN_WEAPON, weld_fire_sound_1, 0.6, ATTN_NORM);
  129.   sound (weld,       CHAN_BODY,   weld_fire_sound_2, 1,   ATTN_NORM);
  130. };
  131.  
  132. //==================================================================
  133. //   WeldTouch
  134. //==================================================================
  135.  
  136. void() WeldExplode1 = [0, WeldExplode2] {};
  137. void() WeldExplode2 = [3, WeldExplode3] {};
  138. void() WeldExplode3 = [4, SUB_Remove]   {};
  139.  
  140. float WELD_DAMAGE_RADIUS = 70;
  141.  
  142. void() WeldTouch =
  143. {
  144.   local float r,d,db;
  145.   local entity e;
  146.  
  147.   if (pointcontents(self.origin) == CONTENT_SKY) {
  148.     remove(self);
  149.     return;
  150.   }
  151.  
  152.   if (other.takedamage) { spawn_touchblood (9); }
  153.   e = findradius(self.origin, WELD_DAMAGE_RADIUS);
  154.   while (e) {
  155.     if (e.takedamage) {
  156.       if (e.takedamage != DAMAGE_AIM) {
  157.     T_Damage (e, self, self.owner, 10);
  158.       } else {
  159.     r  = random();
  160.     db = 10 + (0.5 - r)*6;
  161.     d  = vlen(e.origin + '0 0 16' - self.origin);
  162.     if      (d<WELD_DAMAGE_RADIUS - 4*db) d = db;
  163.     else if (d<WELD_DAMAGE_RADIUS) d = (WELD_DAMAGE_RADIUS-d)*0.25;
  164.     else d = 0;
  165.     if (d) {
  166.       T_Damage (e, self, self.owner, d);
  167.       if (r > 0.85) {            //#jp#(Burn)
  168.         if (d > 5) {            //#jp#(Burn)
  169.           BurnSetOnFire(e,self.owner);    //#jp#(Burn)
  170.         }                    //#jp#(Burn)
  171.       }                    //#jp#(Burn)
  172.     }
  173.       }
  174.     }
  175.     e = e.chain;
  176.   }
  177.   self.origin    = self.origin - 4 * normalize(self.velocity);
  178.   self.movetype  = MOVETYPE_NONE;
  179.   self.velocity  = '0 0 0';
  180.   self.touch     = SUB_Null;
  181.   self.solid     = SOLID_NOT;
  182.   self.think     = SUB_Remove;  // be on the
  183.   self.nextthink = time + 4;    // safe side
  184.   setmodel(self, "progs/s_explod.spr");
  185.   setorigin(self, self.origin);
  186.   sound (self, CHAN_BODY, weld_explode_sound, 1, ATTN_NORM);
  187.  
  188.   WeldExplode1();
  189. };
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.